package com.itzzj.common.config;

import com.itzzj.common.properties.entity.MinIOProperties;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(value = {MinIOProperties.class})
public class MinIOConfig {

    @Autowired
    private MinIOProperties minIOProperties;

    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder().endpoint(minIOProperties.getUrl())
                .credentials(minIOProperties.getName(),minIOProperties.getPass()).build();
    }

}
